home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / config / i386-emul / dispatch.s < prev    next >
Text File  |  1996-10-24  |  2KB  |  153 lines

  1. #    (C) 1995-96 AROS - The Amiga Replacement OS
  2. #    $Id: dispatch.s,v 1.9 1996/10/24 15:51:11 aros Exp $
  3. #
  4. #    Desc: Exec function Dispatch()
  5. #    Lang: english
  6.  
  7. #*****************************************************************************
  8. #
  9. #   NAME
  10. #    AROS_LH0(void, Dispatch,
  11. #
  12. #   LOCATION
  13. #    struct ExecBase *, SysBase, 7, Exec)
  14. #
  15. #   FUNCTION
  16. #
  17. #   INPUTS
  18. #
  19. #   RESULT
  20. #
  21. #   NOTES
  22. #
  23. #   EXAMPLE
  24. #
  25. #   BUGS
  26. #
  27. #   SEE ALSO
  28. #
  29. #   INTERNALS
  30. #
  31. #   HISTORY
  32. #
  33. #******************************************************************************
  34.  
  35.     .include "machine.i"
  36.  
  37.     .text
  38.     .balign 16
  39.     .globl    _Exec_Dispatch
  40.     .type    _Exec_Dispatch,@function
  41.  
  42. _Exec_Dispatch:
  43.     /* Push all registers */
  44.     pushl    %eax
  45.     pushl    %ebx
  46.     pushl    %ecx
  47.     pushl    %edx
  48.     pushl    %edi
  49.     pushl    %esi
  50.     pushl    %ebp
  51.  
  52.     /* Get SysBase */
  53.     movl    32(%esp),%ecx
  54.  
  55.     /* block all signals */
  56.     call    disable
  57.  
  58.     /* Store sp */
  59.     movl    ThisTask(%ecx),%edx
  60.     movl    %esp,tc_SPReg(%edx)
  61.  
  62.     /* Switch bit set? */
  63.     testb    $TF_SWITCH,tc_Flags(%edx)
  64.     je    .noswch
  65.     movl    tc_Switch(%edx),%eax
  66.     call    *%eax
  67.  
  68. .noswch:
  69.     /* Store IDNestCnt */
  70.     movb    IDNestCnt(%ecx),%al
  71.     movb    %al,tc_IDNestCnt(%edx)
  72.     movb    $-1,IDNestCnt(%ecx)
  73.  
  74.     /* Get task from ready list */
  75.     movl    TaskReady(%ecx),%edx
  76.     movl    (%edx),%eax
  77.     movl    %eax,TaskReady(%ecx)
  78.     movl    (%edx),%eax
  79.     leal    TaskReady(%ecx),%ebx
  80.     movl    %ebx,4(%eax)
  81.     movl    %edx,ThisTask(%ecx)
  82.  
  83.     /* Use as current task */
  84.     movb    $TS_RUN,tc_State(%edx)
  85.     movb    tc_IDNestCnt(%edx),%al
  86.     movb    %al,IDNestCnt(%ecx)
  87.  
  88.     /* Launch bit set? */
  89.     cmpb    $0,tc_Flags(%edx)
  90.     jge    .nolnch
  91.     movl    tc_Launch(%edx),%eax
  92.     call    *%eax
  93.  
  94. .nolnch:
  95.     /* Get new sp */
  96.     movl    tc_SPReg(%edx),%eax
  97.  
  98.     /* Compare agains SPLower */
  99.     cmpl    %eax,tc_SPLower(%edx)
  100.     ja    .alert
  101.  
  102.     /* Compare against SPUpper */
  103.     cmpl    %eax,tc_SPUpper(%edx)
  104.     ja    .ok
  105.  
  106. .alert:
  107.     /* Call Alert() */
  108.     pushl    %ecx
  109.     pushl    $(AT_DeadEnd|AN_StackProbe)
  110.     leal    Alert(%ecx),%eax
  111.     call    *%eax
  112.     /* Function does not return */
  113.  
  114. .called_alert:
  115.     nop
  116.  
  117. .ok:
  118.     /* Put the SP into the correct register after checking */
  119.     movl    %eax,%esp
  120.  
  121.     /* Unblock signals if necessary */
  122.     cmpb    $0,tc_IDNestCnt(%edx)
  123.     jge    .noen
  124.     call    en
  125.  
  126. .noen:
  127.     /* Except bit set? */
  128.     testb    $TF_EXCEPT,tc_Flags(%edx)
  129.     je    .noexpt
  130.  
  131.     /* Raise task exception in Disable()d state */
  132.     pushl    %ecx
  133.     leal    Disable(%ecx),%eax
  134.     call    *%eax
  135.     leal    Exception(%ecx),%eax
  136.     call    *%eax
  137.     movl    (%esp),%ecx
  138.     leal    Enable(%ecx),%eax
  139.     call    *%eax
  140.     addl    $4,%esp
  141.  
  142.     /* Restore registers and return */
  143. .noexpt:
  144.     popl    %ebp
  145.     popl    %esi
  146.     popl    %edi
  147.     popl    %edx
  148.     popl    %ecx
  149.     popl    %ebx
  150.     popl    %eax
  151.     ret
  152.  
  153.